package com.yunhe.java.Day13;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * Created by Administrator on 2017/8/7 0007.
 */
public class Map0 {
    public static void main(String[] args) {
        Map map=new HashMap();
        map.put(1,"赵");
        map.put(2,"钱");
        map.put(3,"孙");
        map.put(4,"李");
        System.out.println(map.get(4));
        //map集合的遍历
//        Set set= map.keySet();
//        Iterator iterator= set.iterator();
//        while(iterator.hasNext()){
//            Object key =iterator.next();
//            Object value=map.get(key);
//            System.out.print(key+":"+value+" ");
            //map集合的遍历方式二
            Set entrys =map.entrySet();
            Iterator iterator2= entrys.iterator();
            while(iterator2.hasNext()){
                Map.Entry entry=(Map.Entry)iterator2.next();
              Object key= entry.getKey();
               Object value= entry.getValue();
                System.out.print(key+":"+value+" ");
            }

        }
    }


